<div class="tabbable tabs-left">
              <ul class="nav nav-tabs">
              	<li><h5><?php echo $this->translate('规则信息'); ?></h5></li>
                <li class="active"><a data-toggle="tab" href="#integral_rule_a"><?php echo $this->translate('基本信息'); ?></a></li>
                <li class=""><a data-toggle="tab" href="#integral_rule_c"><?php echo $this->translate('积分规则'); ?></a></li>
                <li class=""><a data-toggle="tab" href="#integral_rule_b"><?php echo $this->translate('选择客户组'); ?></a></li>
                <li class=""><a data-toggle="tab" href="#integral_rule_d"><?php echo $this->translate('选择商品'); ?></a></li>
              </ul>
              <form class="form-horizontal" method="post" name="integral_rule_add_form" id="integral_rule_add_form" action="">
              <input type="hidden" name="integral_rule_id" id="integral_rule_id" value="<?php echo ($this->integral_rule_info ? $this->integral_rule_info->integral_rule_id : ''); ?>" />
              <input type="hidden" name="integral_rule_save_type" id="integral_rule_save_type" value="" />
              <div class="tab-content">
    			<div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
        			<div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php if($this->integral_rule_info) echo $this->translate('编辑'); else echo $this->translate('新加'); ?><?php echo $this->translate('积分规则'); ?></strong></div>
        			<div id="sticky_navigation_right" class="pull-right">
                	<a href="<?php echo $this->url('integral/default',array('action'=>'integralRule')); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回规则列表'); ?></a>&nbsp;
                	<a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>&nbsp;
                    <?php if($this->integral_rule_info) { ?>
                    <a href="<?php echo $this->url('integral/default/integral_rule_id',array('action'=>'delIntegralRule', 'integral_rule_id'=>$this->integral_rule_info->integral_rule_id)); ?>" onclick="return window.confirm('<?php echo $this->translate('您确实要删除该积分规则吗？'); ?>');" class="btn btn-small btn-danger"><i class="icon-remove icon-white"></i> <?php echo $this->translate('删除积分规则'); ?></a>&nbsp;
                    <button type="submit" onclick="$('#integral_rule_save_type').val('save_return_edit');" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存积分规则并继续编辑'); ?></button>&nbsp;
                    <?php } ?>
                	<button type="submit" onclick="$('#integral_rule_save_type').val('');" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存积分规则'); ?></button>&nbsp;
                	<a href="<?php echo $this->myviewalias()->dbshopHelpUrl('user_integral_rule_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
                	</div>
        		</div>
                <div id="integral_rule_a" class="tab-pane active">
                	<div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                	<div class="well admin_add_well">
                        <div class="message_one">
                    	</div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('规则名称'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
              					<input type="text" id="integral_rule_name"  name="integral_rule_name" value="<?php echo ($this->integral_rule_info ? $this->escapeHtml($this->integral_rule_info->integral_rule_name) : ''); ?>" class="span3">
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('规则描述'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="integral_rule_info"  name="integral_rule_info" value="<?php echo ($this->integral_rule_info ? $this->escapeHtml($this->integral_rule_info->integral_rule_info) : ''); ?>" class="span6"> <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('前台购物车处显示此信息。'); ?>"></i>
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('开始时间'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="integral_rule_start_time"  name="integral_rule_start_time" value="<?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_start_time != '') echo date("Y-m-d H:i",$this->integral_rule_info->integral_rule_start_time); ?>" onclick="WdatePicker({el:'integral_rule_start_time', dateFmt:'yyyy-MM-dd HH:mm'})" class="span2 Wdate"> <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('请在此填写有效的开始时间，为空，则不限时间。'); ?>"></i>
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('结束时间'); ?>：</label>
           					<div class="controls">
              					<input type="text" id="integral_rule_end_time"  name="integral_rule_end_time" value="<?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_end_time != '') echo date("Y-m-d H:i",$this->integral_rule_info->integral_rule_end_time); ?>" onclick="WdatePicker({el:'integral_rule_end_time', dateFmt:'yyyy-MM-dd HH:mm'})" class="span2 Wdate"> <i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('请在此填写有效的结束时间，为空，则不限时间。'); ?>"></i>
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('规则状态'); ?>：</label>
           					<div class="controls">
              					<select name="integral_rule_state" id="integral_rule_state" class="span1">
                                	<option value="1" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_state == 1) echo 'selected="selected"'; ?>><?php echo $this->translate('开启'); ?></option>
                                    <option value="2" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_state == 2) echo 'selected="selected"'; ?>><?php echo $this->translate('关闭'); ?></option>
                                </select>
            				</div>                        
                        </div>                                                                 
                  	</div>
                </div>                
                 <div id="integral_rule_b" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('选择客户组'); ?></div>
                	<div class="well admin_add_well">
                        <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('选择客户组类型'); ?>：</label>
           					<div class="controls">
              					<select name="integral_rule_user_type" id="integral_rule_user_type" class="span2" onchange="select_integral_rule_user();">
                                	<option value="all_user" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_user_type == 'all_user') echo 'selected="selected"'; ?>><?php echo $this->translate('所有客户'); ?></option>
                                    <option value="user_group" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_user_type == 'user_group') echo 'selected="selected"'; ?>><?php echo $this->translate('个性化客户组'); ?></option>
                                </select>
            				</div>                        
                        </div>
                     	<div class="control-group integral_rule_user_display" id="integral_rule_user_group" <?php if (($this->integral_rule_info and $this->integral_rule_info->integral_rule_user_type == 'all_user') or !isset($this->integral_rule_info)) echo 'style="display:none;"'; ?>>
                  			<label for="input01" class="control-label"><?php echo $this->translate('个性化客户组'); ?>：</label>
           					<div class="controls">
            				<?php
								$selectUserGroup = ($this->integral_rule_info and $this->integral_rule_info->integral_rule_user_group != '') ? unserialize($this->integral_rule_info->integral_rule_user_group) : array();
								if ($this->group_array) {
									foreach ($this->group_array as $group_val) {
							?>
                            	<label class="checkbox"><input type="checkbox" name="integral_rule_user_group[]" <?php if(!empty($selectUserGroup) and in_array($group_val['group_id'], $selectUserGroup)) echo 'checked="checked"'; ?> value="<?php echo $group_val['group_id']; ?>" /><?php echo $this->escapeHtml($group_val['group_name']); ?></label>
                            <?php } } ?>
            				</div>                        
                        </div>                                         
                  	</div>                                         
              </div>
                 <div id="integral_rule_c" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('积分规则'); ?></div>
                	<div class="well admin_add_well">
                        <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('购物金额'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
								<select class="span1" name="shopping_type" style="width: 60px;">
									<option value="1" <?php echo (isset($this->integral_rule_info->shopping_type) and $this->integral_rule_info->shopping_type == 1) ? 'selected' : ''; ?>><?php echo $this->translate('满'); ?></option>
									<option value="2" <?php echo (isset($this->integral_rule_info->shopping_type) and $this->integral_rule_info->shopping_type == 2) ? 'selected' : ''; ?>><?php echo $this->translate('每'); ?></option>
								</select>
              					<input type="text" id="shopping_amount"  name="shopping_amount" value="<?php echo ($this->integral_rule_info ? $this->integral_rule_info->shopping_amount : ''); ?>" class="span2">&nbsp;<?php echo $this->translate('元'); ?>
								<i class="cus-help shop_admin_help_note" data-content="<?php echo $this->translate('满：例如 填写的 100 元 获得 5 积分，那么前台买家购物1000元，依然得到 5积分。<br>每：例如填写的是 100 元 获得 5 积分 ，那么前台买家购物1000元，将会得到 50 积分。'); ?>"></i>
            				</div>

                        </div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('获得'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
								<select class="span2" name="integral_type_id" id="integral_type_id">
									<?php if($this->integral_type) {
										foreach ($this->integral_type as $integral_type_val) {
											?>
											<option value="<?php echo $integral_type_val['integral_type_id']; ?>" <?php if($this->integral_rule_info and $this->integral_rule_info->integral_type_id == $integral_type_val['integral_type_id']) echo 'selected'; ?>><?php echo $this->escapeHtml($integral_type_val['integral_type_name']); ?></option>
										<?php } } ?>
								</select>
              					<input type="text" id="integral_num"  name="integral_num" value="<?php echo ($this->integral_rule_info ? $this->integral_rule_info->integral_num : ''); ?>" class="span1">
                                <?php echo $this->translate('积分'); ?>
            				</div>                        
                        </div>                                   
                  	</div>                                         
              </div>
               <div id="integral_rule_d" class="tab-pane">
                	<div class="well admin_add_header_well"><?php echo $this->translate('选择商品'); ?></div>
                	<div class="well admin_add_well">
                        <div class="message_one">
                    	</div>
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('选择商品类型'); ?>：</label>
           					<div class="controls">
              					<select name="integral_rule_goods_type" id="integral_rule_goods_type" class="span2" onchange="select_integral_rule_goods();">
                                	<option value="all_goods" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_goods_type == 'all_goods') echo 'selected="selected"'; ?>><?php echo $this->translate('所有商品'); ?></option>
                                    <option value="class_goods" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_goods_type == 'class_goods') echo 'selected="selected"'; ?>><?php echo $this->translate('商品分类'); ?></option>
                                    <option value="brand_goods" <?php if ($this->integral_rule_info and $this->integral_rule_info->integral_rule_goods_type == 'brand_goods') echo 'selected="selected"'; ?>><?php echo $this->translate('商品品牌'); ?></option>
                                </select>
            				</div>                        
                        </div>
                        <?php
                        $selectGoodsType = ($this->integral_rule_info and $this->integral_rule_info->integral_rule_goods_content != '') ? unserialize($this->integral_rule_info->integral_rule_goods_content) : array();
						?>
                     	<div class="control-group integral_rule_type" id="integral_rule_goods_class" <?php if (($this->integral_rule_info and ($this->integral_rule_info->integral_rule_goods_type == 'all_goods' or $this->integral_rule_info->integral_rule_goods_type == 'brand_goods')) or !isset($this->integral_rule_info)) echo 'style="display:none;"'; ?>>
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品分类'); ?>：</label>
           					<div class="controls">
                                <?php
                                if ($this->goods_class) {
                                	foreach ($this->goods_class as $class_val) {
								?>
                  				<label class="checkbox"  style="margin-left:<?php echo $class_val['class_level'] * 20; ?>px;"><input type="checkbox" name="class_id[]" value="<?php echo $class_val['class_id']; ?>" <?php if(!empty($selectGoodsType) and in_array($class_val['class_id'], $selectGoodsType)) echo 'checked="checked"'; ?>><?php echo $this->escapeHtml($class_val['class_name']); ?></label>
                                <?php
                                	}
                                }
								?>
            				</div>                        
                        </div>
                     	<div class="control-group integral_rule_type" id="integral_rule_goods_brand" <?php if (($this->integral_rule_info and ($this->integral_rule_info->integral_rule_goods_type == 'all_goods' or $this->integral_rule_info->integral_rule_goods_type == 'class_goods')) or !isset($this->integral_rule_info)) echo 'style="display:none;"'; ?>>
                  			<label for="input01" class="control-label"><?php echo $this->translate('商品品牌'); ?>：</label>
           					<div class="controls">
                                <?php
                                if ($this->goods_brand) {
                                	foreach ($this->goods_brand as $brand_val) {
								?>
                  				<label class="checkbox"><input type="checkbox" name="brand_id[]" value="<?php echo $brand_val['brand_id']; ?>" <?php if(!empty($selectGoodsType) and in_array($brand_val['brand_id'], $selectGoodsType)) echo 'checked="checked"'; ?>><?php echo $this->escapeHtml($brand_val['brand_name']); ?></label>
                                <?php
                                	}
                                }
								?>
            				</div>                        
                        </div>                                  
                  	</div>                                         
              </div>
              
             </div>
              </form>
</div>
<script src="<?php echo $this->basePath('/public/js/DatePicker/WdatePicker.js'); ?>"></script>
<script>
$(document).ready(function() {
	$("#integral_rule_add_form").validate({
		rules: {
			integral_rule_name: {
				required: true
			},
			shopping_amount: {
				required: true,
				number: true,
				min:1
			},
			integral_num: {
				required: true,
				number: true,
				min:1
			}
		},
		messages: {
			integral_rule_name: {
				required: "<?php echo $this->translate('积分规则名称不能为空！'); ?>"
			},
			shopping_amount: {
				required: "<?php echo $this->translate('购物金额满不能为空！'); ?>",
				number: "<?php echo $this->translate('购物金额满必须为数字！'); ?>",
				min:"<?php echo $this->translate('数字最小为1'); ?>"
			},
			integral_num: {
				required: "<?php echo $this->translate('获得积分数不能为空！'); ?>",
				number: "<?php echo $this->translate('获得积分数必须为数字！'); ?>",
				min:"<?php echo $this->translate('获得积分数最小为1'); ?>"
			}
		}
	});
});

<?php if ($this->success_msg != '') { ?>
show_message('.message_one','<?php echo date("Y-m-d H:i:s"); ?>','<?php echo $this->success_msg; ?>','alert-success');
<?php } ?>

//商品js处理
function select_integral_rule_goods() {
	var integral_rule_goods_type_value = $('#integral_rule_goods_type').val();
	$('.integral_rule_type').css('display', 'none');
	
	if(integral_rule_goods_type_value == 'class_goods') {
		$('#integral_rule_goods_class').css('display', '');
	}else if (integral_rule_goods_type_value == 'brand_goods') {
		$('#integral_rule_goods_brand').css('display', '');
	}
}
//会员js处理
function select_integral_rule_user() {
	var integral_rule_user_type_value = $('#integral_rule_user_type').val();
	$('.integral_rule_user_display').css('display', 'none');
	
	if(integral_rule_user_type_value == 'user_group') {
		$('#integral_rule_user_group').css('display', '');
	}
}
</script>
